package com.sc.ktapplication.module.fragment

import android.app.Application
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.sc.ktapplication.common.base.BaseViewModel
import com.sc.ktapplication.common.net.RetrofitManager
import com.sc.ktapplication.common.net.WebApi
import com.sc.ktapplication.module.entity.Equipment
import kotlinx.coroutines.launch

class RecordViewModel(application: Application) : BaseViewModel(application) {

    val equipments = MutableLiveData<MutableList<Equipment>>()

    fun getEquipments(params : HashMap<String,Any>){
        viewModelScope.launch {
            val ret = RetrofitManager.instance.create(WebApi::class.java).getEquipments(params)
            if(ret.isSuccess){
                equipments.postValue(ret.data)
            }else{
                errorMsg.postValue(ret.errorMsg)
            }
        }
    }

}